package cc.kzc.adminauth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

	@Value("${local.data.root:/data}")
	private String LOCAL_DATA_ROOT;

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// 重写这个方法，映射静态资源文件
		registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/")
				.addResourceLocations("classpath:/resources/").addResourceLocations("classpath:/static/")
				.addResourceLocations("classpath:/public/");
		//
		registry.addResourceHandler("/log/**").addResourceLocations("file:" + LOCAL_DATA_ROOT + "/logs/adminauth/");
		super.addResourceHandlers(registry);
	}

}
